/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.manager;

import br.com.deployment.entidade.protocolo.Protocolo;
import br.com.deployment.servico.ProtocoloServico;
import br.com.deployment.servico.TramiteServico;
import java.io.Serializable;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author roniere
 */
@ManagedBean
@ViewScoped
public class ManagerTramiteRelatorio implements Serializable {
    
    @EJB
    TramiteServico tramiteServico;
    
    @EJB
    ProtocoloServico protocoloServico;
     
    private String cod;

    public ManagerTramiteRelatorio() {
        
        HttpServletRequest request = (HttpServletRequest) FacesContext
        .getCurrentInstance().getExternalContext().getRequest(); 
        
        if(request.getParameter("imovel") != null ){
            relatorio(Integer.parseInt(request.getParameter("imovel")));
        }
    }
    
    

    public String getCod() {
        return cod;
    }

    public void setCod(String cod) {
        this.cod = cod;
    }
     
    public void relatorio(){
        Protocolo p = new Protocolo();
        p.setId(Integer.parseInt(cod));
        tramiteServico.relatorio(p);
    } 
    
    
    public void relatorio(Integer id){
        tramiteServico.relatorio(protocoloServico.find(id));
    } 
}
